package com.example.myapplication.fragment;

import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

import com.example.myapplication.BaseFgm;
import com.example.myapplication.R;

public class SquareFgm extends BaseFgm {
    private TextView bt1,bt2;
    private BaseFgm squareFgm,recycleFgm;

    @Override
    protected void logicStart() {
        getChildFragmentManager().beginTransaction().add(R.id.rp,squareFgm).add(R.id.rp,recycleFgm).show(squareFgm).hide(recycleFgm).commitAllowingStateLoss();

    }

    @Override
    protected void initView() {
        bt1=rootView.findViewById(R.id.btOne);
        bt2=rootView.findViewById(R.id.btTwo);
        squareFgm=new SquareChildFgm();
        recycleFgm=new RecycleFgm();

    }

    @Override
    protected void setListener() {
        bt1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                bt1.setTextColor(Color.parseColor("#ffffff"));
                bt1.setBackgroundResource(R.drawable.e88b00_l_5r);

                bt2.setTextColor(Color.parseColor("#e88b00"));
                bt2.setBackgroundResource(R.drawable.fff_r_5r);

                getChildFragmentManager().beginTransaction().show(squareFgm).hide(recycleFgm).commitAllowingStateLoss();

            }
        });

        bt2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                bt1.setTextColor(Color.parseColor("#e88b00"));
                bt1.setBackgroundResource(R.drawable.fff_l_5r);

                bt2.setTextColor(Color.parseColor("#ffffff"));
                bt2.setBackgroundResource(R.drawable.e88b00_r_5r);

                getChildFragmentManager().beginTransaction().show(recycleFgm).hide(squareFgm).commitAllowingStateLoss();
            }
        });
    }

    @Override
    public void refreshState() {
        super.refreshState();
        squareFgm.refreshState();
        recycleFgm.refreshState();
    }

    @Override
    protected int getlayout() {
        return R.layout.fgm_square;
    }
}
